
    $(document).ready(function () {
 
        //Prepare jtable plugin
        $('#StudentTableContainer').jtable({
            title: 'Liste des Mecanicien',
            selecting: true,
            paging: true, //Enables paging
            pageSize: 10, //Actually this is not needed since default value is 10.
            sorting: true, //Enables sorting
            defaultSorting: 'Nom ASC', //Optional. Default sorting on first load.
            
            actions: {
            	listAction: '/piloteOrdo/mecanicien/getAllMecanicien',
                createAction: '/piloteOrdo/jalon/addMecanicien',
                updateAction: '/piloteOrdo/mecanicien/updateMecanicien',
                deleteAction: '/piloteOrdo/mecanicien/deleteMecanicien'
            },
            fields: {
            	 Id: {
                     key: true,
                     create: false,
                     edit: false,
                     list: false
                 },
                 Nom: {
                     title: 'Nom',
                     width: '23%'
                 },
                 Prenom: {
                     title: 'Prenom',
                     width: '23%'
                 },
                 Specialite: {
                     title: 'Specialite',
                     width: '23%'
                 },
                 Leader : {
                	 title: 'Leader',
                     options:'${pageContext.request.contextPath}/mecanicien/leader'
                 }
            },
    		rowInserted : function(event, data) {
    			$('#StudentTableContainer').jtable('selectRows', data.row);
    			console.log("records inserted");
    		},
    		// Register to selectionChanged event to hanlde events
    		recordAdded : function(event, data) {
    			// after record insertion, reload the records
    			$('#StudentTableContainer').jtable('load');
    		},
    		recordUpdated : function(event, data) {
    			// after record updation, reload the records
    			$('#StudentTableContainer').jtable('load');
    		},
    		
    		//Initialize validation logic when a form is created
            formCreated: function (event, data) {
                data.form.validationEngine();
            },
            //Validate form when it is being submitted
            formSubmitting: function (event, data) {
                return data.form.validationEngine('validate');
            },
            //Dispose validation logic when form is closed
            formClosed: function (event, data) {
                data.form.validationEngine('hide');
                data.form.validationEngine('detach');
            }

        });
 
        //Load student list from server
        $('#StudentTableContainer').jtable('load');
    });